package com.bluebench.bigul.domain;

import java.lang.reflect.InvocationTargetException;

import com.bluebench.bigul.exception.GraphicInitializationException;
import com.bluebench.bigul.service.processor.Processor;
import com.bluebench.bigul.service.resolver.Resolver;

public abstract class Tag {
	
	private String id;
	private String name;
	private String type;
	private String field;
	private String expression;
	private String user;
	private String owner;
	private Position position;
	private boolean allowPrint=true;
	private boolean allowCopy=true;
	private boolean isGraphic=false;
	private ElementType elementType;
	private Resolver resolver;
	private Processor processor; 
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		if(this.name==null){
			this.name = name;
		}
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getExpression() {
		return expression;
	}
	public void setExpression(String expression) {
		this.expression = expression;
	}
	public ElementType getElementType() {
		return elementType;
	}
	public void setElementType(ElementType elementType) {
		this.elementType = elementType;
	}
	public Resolver getResolver() {
		return resolver;
	}
	public void setResolver(Resolver resolver) {
		this.resolver = resolver;
	}
	public Processor getProcessor() {
		return processor;
	}
	public void setProcessor(Processor processor) {
		this.processor = processor;
	}
		
	public void resolve() throws GraphicInitializationException {
		Resolver r = this.getResolver();
		r.set(this);
		r.resolve();		
	}
	
	public Object process() throws SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchFieldException, GraphicInitializationException{
		Processor p = this.getProcessor();
		p.set(this);
		Object o = p.process();
		return o;
	}
	public String getField() {
		return field;
	}
	public void setField(String field) {
		this.field = field;
	}
	public String getUser() {
		return user;
	}
	public void setUser(String user) {
		this.user = user;
	}
	public String getOwner() {
		return owner;
	}
	public void setOwner(String owner) {
		this.owner = owner;
	}
	public boolean isAllowPrint() {
		return allowPrint;
	}
	public void setAllowPrint(boolean allowPrint) {
		this.allowPrint = allowPrint;
	}
	public boolean isAllowCopy() {
		return allowCopy;
	}
	public void setAllowCopy(boolean allowCopy) {
		this.allowCopy = allowCopy;
	}
	public Position getPosition() {
		return position;
	}
	public void setPosition(Position position) {
		this.position = position;
	}
	public boolean isGraphic() {
		return isGraphic;
	}
	public void setGraphic(boolean isGraphic) {
		this.isGraphic = isGraphic;
	}
	
}
